package com.ieheima.ai.memory;


import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Component
public class ChatMap implements ChatMapInter{


    private final Map<String,List<String>> map=new HashMap<>();

    @Override
    public void save(String type, String chatId) {
        List<String> ids = map.computeIfAbsent(type, k -> new ArrayList<>());
        if(ids.contains(chatId))
            return;

        ids.add(chatId);
    }

    @Override
    public List<String> get(String type) {

        List<String> ids = map.getOrDefault(type,new ArrayList<>());

        return ids;
    }
}
